from collections import deque

class Solution:
    def maxAreaOfIsland(self, e: List[List[int]]) -> int:
        maxs=0
        for i in range(len(e)):
            for j in range(len(e[i])):
                if e[i][j]==1:
                    lists=deque([(i,j)])
                    a=1
                    e[i][j]=0
                    while lists: 
                        y, x = lists.popleft()
                        lst = [(y+1, x), (y-1, x), (y, x+1), (y, x-1)]
                        for m, n in lst:
                            if 0<=m<len(e) and 0<=n<len(e[i]):
                                if e[m][n]==1:
                                    lists.append((m,n))
                                    e[m][n]=0
                                    a+=1
                    if a>maxs:
                        maxs=a
                    
        return maxs
          
